﻿using System;
using Birkelund.QueryStrings.Tokens;
using NUnit.Framework;
using Birkelund.QueryStrings.Internals;

namespace Birkelund.QueryStrings.Test
{
    public class UriWriterFluentTest
    {
        [Test]
        public void FluentAPITest()
        {
            Uri initialUrl = new Uri(@"http://localhost/test/testFile.aspx?dummy=123");
            string expected = new Uri(@"http://localhost/test/testFile.aspx?a=10&b=False").ToString();

            IQueryStringToken<int> a = new ValueTypeToken<int>("a");
            IQueryStringToken<bool> b = new ValueTypeToken<bool>("b");

            IUriWriter writer = UriWriter.CreateFromUri(initialUrl)
                .RemoveTokenAll()
                .SetToken(a, 10)
                .SetToken(b, false);

            Assert.AreEqual(expected, writer.GenerateQueryAsString());
        }
    }
}
